package com.guli.eduService.controller;


import com.guli.commonUtils.R;
import com.guli.eduService.entity.vo.VideoFormInfo;
import com.guli.eduService.service.impl.EduVideoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author zxc
 * @since 2023-04-03
 */
@Api(description = "课时基本信息模块")
@RestController
@RequestMapping("/eduService/eduVideo")
//@CrossOrigin // 解决跨域问题
public class EduVideoController {
    @Autowired
    private EduVideoServiceImpl videoService;

    @ApiOperation(value = "添加课时基本信息")
    @PostMapping("addVideoInfo")
    public R addVideoInfo(
            @ApiParam(name = "videoFormInfo" , value = "课时基本信息" , required = true)
            @RequestBody VideoFormInfo videoFormInfo){
        boolean flag = videoService.savaVideoData(videoFormInfo);
        return R.ok().message("添加课时基本信息成功~~~");
    }

    @ApiOperation(value = "修改课时基本信息")
    @PostMapping("updateVideoInfo")
    public R updateVideoInfo(
            @ApiParam(name = "videoFormInfo" , value = "课时基本信息" , required = true)
            @RequestBody VideoFormInfo videoFormInfo){
        boolean flag = videoService.updateVideoData(videoFormInfo);
        return R.ok().message("修改课时基本信息成功~~~");
    }

    @ApiOperation(value = "根据课时id，查询指定的课时基本信息")
    @GetMapping("queryVideoInfo/{videoId}")
    public R queryVideoInfo(
            @ApiParam(name = "videoId" , value = "课时id" , required = true)
            @PathVariable String videoId){
        VideoFormInfo videoFormInfo = videoService.queryVideoData(videoId);
        return R.ok().data("videoFormInfo" , videoFormInfo);
    }

    @ApiOperation(value = "根据课时id，删除指定的课时基本信息")
    @DeleteMapping("deleteVideoInfo/{videoId}")
    public R deleteVideoInfo(
            @ApiParam(name = "videoId" , value = "课时id" , required = true)
            @PathVariable String videoId){
        boolean flag = videoService.deleteVideoData(videoId);
        return R.ok().message("删除课程基本信息成功~~~");
    }
}

